// rollup.config.js
// umd
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from "rollup-plugin-terser";
import typescript from "@rollup/plugin-typescript"

import { banner, name } from './rollup.js';

const prod = process.env.NODE_ENV === 'production';

export default {
    input: 'src/index.ts',
    output: {
        file: prod ? 'lib/index.min.js' : 'lib/index.js',
        format: 'umd',
        // When export and export default are not used at the same time, set legacy to true.
        // legacy: true,
        name,
        banner,
    },
    plugins: [
        nodeResolve({
            extensions: ['.ts', '.js', '.css']
        }),
        commonjs({
            include: 'node_modules/**',
        }),
        typescript(),
        (prod && terser()),

    ]
};
